Repository navigation
feat(codegen-ts): template generator renders the docs view - #666
Merged
Merged
Conversation
Documentation pages become ordinary configured Mustache templates over the
port-neutral docs view, run by the existing template generator.
- Two scopes walk the view: perNode (one file per top-level node of any
type, filtered by `match`: "<type>.<subType>", "<type>.*", "*" or a list)
and perRequirement (one per requirement at any depth). perModel and
perPackage read the view with `data: "docsView"`; without it they keep the
per-entity dictionary, so existing specs render the same bytes.
- `{path}` in outputPattern is the page the view gives a node or
requirement; every docs-view page gets `root`, the way back to the site
root, so `{{root}}{{path}}` links from any page. `subDir` sets the site
directory.
- `assets: { from, to }` copies a directory of text files beside the pages.
- `linkCheck: true` fails the run, writing nothing, when a relative link in
an entry's HTML pages lands on no file or anchor. It runs through a new
`Generator.checkRunOutput` hook, called once every generator has rendered,
so links to pages a later entry renders are checked too. docs-site's link
check is split into a pure `findDanglingLinks` the generator reuses.
- The run's docs view is built in one place (docs-view-run.ts), shared with
docsSiteFile().
- JSON template spec and its schema take the same keys.
- fixtures/template-codegen-conformance/docs-view/: a second case pinning the
scopes, path output, subDir, assets and link check for the other ports.
The explorer site is unchanged.
This was referenced Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
templategenerator (server/typescript/packages/codegen-ts/src/generators/template-generator.ts) gainsperNodeandperRequirementscopes over the docs view, adata: "docsView"option forperPackage/perModel(default still the per-entity dictionary),matchto filter nodes by<type>.<subType>,{path}inoutputPattern, and arootvalue on each page for relative links.subDir,assets: { from }(copies a directory of UTF-8 text files) andlinkCheckare also added, and the same keys are accepted in the JSON template spec (template-spec.ts,template-spec.schema.json).linkCheckruns through a newGenerator.checkRunOutputhook, called fromrunGenafter all generators render and before any write, so a dangling link fails the run and writes nothing.docs-siteexports the check asfindDanglingLinks, and the docs view is built per run indocs-view-run.ts.template-codegen-conformancegains adocs-view/case (metadata, templates, assets and expected output), anddocs/features/codegen-concepts.md,docs/features/docs-view.mdandCHANGELOG.mddocument the new scopes. The explorer site output is unchanged.Validation
Risk Assessment
✅ Low: The change adds opt-in features to the template generator, and existing specs keep the per-entity dictionary and their bytes. The fix round resolved F1 (the link check now ignores stale generated files in a sweeping run), F2 (in perNode, "*" skips requirement nodes) and F3 (assets.to removed everywhere, corpus bytes unchanged), each with a test that has an independent oracle. I found no new defects.
Testing
Ran the template-codegen conformance corpus and docs-view generator tests for the docs-view feature: 39 pass, 0 fail. Those tests execute the real generator in process against the committed fixture and scratch dirs, so they are not live product drives. The
meta genCLI was not driven live on a disposable project, so all three scenarios are untested-live. Verdict inconclusive, not no-go: nothing failed. Broad regression came from the configured baseline command, which passed.Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/typescript/packages/codegen-ts/src/runner.ts:1108- The link check falls back to disk for any path this run did not emit (runner.ts:1108-1116), including generated files from an earlier run that this full run no longer produces. The run-wide orphan sweep (runner.ts:1246-1264, which runs only when generatorNames is undefined) then deletes those files after the check passed. Concrete sequence: a perNode entry with match "" wrote model/acme/Foo.prompt-…html last run; the user narrows match to "object."; a requirement page (linkCheck) still links to that node's {{root}}{{path}}; the fullmeta genpasses the check by reading the stale page from disk, then the sweep removes it, and the site ships a dangling link. The check claims every link lands. Fix: in a run that sweeps (opts.generatorNames undefined and no entity filter), do not answer from disk for a path recorded in the gen-state manifest (listGeneratedPaths) that this run did not emit. Keep the disk fallback for narrowed runs and for hand-authored files.server/typescript/packages/codegen-ts/src/generators/template-generator.ts:260-perNodedefaults to match "*", and view.nodes holds top-level requirement nodes. Theirpathis requirements/<pkg>/<Name>.html, the same page perRequirement writes. The test 'match takes a list, and * matches every node type' confirms this: it writes b/Buy.txt for a requirement. So the natural full-site config (a perNode entry with the default match plus a perRequirement entry, both at outputPattern "{path}" in one subDir) fails with "Output path collision" on every top-level requirement.matchhas no exclusion form, so 'every node except requirements' means listing each other type by hand. Decide one of: perNode skips requirement-type nodes (perRequirement owns their pages),matchgains an exclusion, or the docs warn about it (codegen-concepts.md, the perNode bullet). Same rule at template-generator.ts:184-187 (the perNode walk).server/typescript/packages/codegen-ts/src/generators/template-generator.ts:64- Simplification:assets.to, which re-roots the copied assets under subDir (also in template-spec.ts, template-spec.schema.json and assetFiles at line 225), goes beyond the intent's "copying a directory of static assets". Copyingfromstraight under subDir is the narrower form: the author names the source directory to match the layout they want (e.g. from: "site/assets"). Recommend removingtounless a concrete layout needs it.docs/ports/typescript.md:224- Changed 'Abstract objects are excluded from every scope' to say they are excluded only from the scopes that read the per-entity dictionary, and that the docs-view scopes include them. The fixture renders the abstract BaseEntity through perNode.fixtures/template-codegen-conformance/README.md:9- Changed 'The corpus exercises all three built-in scopes' to 'The root case exercises the three per-entity-dictionary scopes'. There are now five scopes, and the docs-view/ case covers the other two.🔧 Fix applied.
📝 2 wording or comment-placement notes left for the author (no fix round spent):
docs/ports/typescript.md:224- Changed 'Abstract objects are excluded from every scope' to say they are excluded only from the scopes that read the per-entity dictionary, and that the docs-view scopes include them. The fixture renders the abstract BaseEntity through perNode.fixtures/template-codegen-conformance/README.md:9- Changed 'The corpus exercises all three built-in scopes' to 'The root case exercises the three per-entity-dictionary scopes'. There are now five scopes, and the docs-view/ case covers the other two.meta genwith docs-view generators. Coverage is in-process via bun test over the real generator and fixture. Live validation would need a disposable project wiring templateSpecToGenerators into metaobjects.config.ts. Not built in this turn.scripts/ci-local.sh --affected --strict-toolchainscd server/typescript && bun test packages/codegen-ts/test/template-codegen packages/codegen-ts/test/generators/template-generator-docs-view.test.ts (39 pass, 0 fail)Covered by that run: perNode at {path} with root; match list and * default; full site with perNode plus perRequirement writes each page once; perRequirement and perModel/perPackage with docsView; broken link fails run and writes nothing; full run does not link to a stale generated file; link check sees later-rendered pages and assets; non-UTF-8 and missing assets refused; {path} outside perNode/perRequirement rejected; config parse and malformed-value refusalConfigured baselinescripts/ci-local.sh --affected --strict-toolchainspassed at this target commit (broad regression; not re-run, no source changed this turn)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.